<template>
  <div>
    <h1>{{ count }}</h1>
    <a-input :value="count"></a-input>
    <a-button @click="add">+1</a-button>
  </div>
</template>

<script lang="ts">
import {defineComponent, computed} from "vue";
import {useStore} from "vuex";

export default defineComponent({
  name: "vuex",
  components: {},
  setup() {
    console.log(useStore())
    const store = useStore()
    // const num = ref(store.state.count);
    // const count = store.state.count;
    // console.log(num)
    // const count = num.value
    // console.log(count)

    // ! 只有getter的计算属性
    const count = computed(() => {
      return store.state.count
    })

    const add = () => {
      store.commit('increment');
    }
    return {
      count,
      add
    }
  }
})
</script>

<style lang="less" scoped>

</style>